﻿using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations.Model;
using System.Data.Entity.SqlServer;
using System.Linq;
using System.Text;
using Hyt.Core;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Transactions;
using Hyt.Data.Ef;

namespace Hyt.Passport.Persist
{
    public class PassportPersistService : HytDbContext, IPersistService
    {
        #region 静态构造方法
        /// <summary>
        /// 初始化
        /// </summary>
        static PassportPersistService()
        {
            Database.SetInitializer<PassportPersistService>(
                   new MigrateDatabaseToLatestVersion<PassportPersistService, HytDbContext.HytDbMigrationsConfiguration<PassportPersistService>>());
            //System.Data.Entity.Database.SetInitializer<PassportPersistService>(null);
        }
        #endregion
        
        #region 构造方法
        /// <summary>
        /// 初始化
        /// </summary>
        public PassportPersistService()
            : base("Name=Passport")
        {
          
        }
        #endregion

        #region 创建实体模型
        /// <summary>
        /// 创建实体模型
        /// </summary>
        /// <param name="modelBuilder">实体模型生成器</param>
        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            new PassportMapping().RegisterTo(modelBuilder);
        }
        #endregion

    }
}
